package com.company.command;

/**
 * 请求者角色，遥控器
 */
public class RemoteControlInvoker {

    //持有开机命令对象的引用
    private Command onCommand;
    //持有前进命令对象的引用
    private Command forwardCommand;
    //持有后退命令对象的引用
    private Command backCommand;
    //持有左转命令对象的引用
    private Command leftCommand;
    //持有右转命令对象的引用
    private Command rightCommand;
    //持有关机命令对象的引用
    private Command offCommand;


    public void setOnCommand(Command onCommand) {
        this.onCommand = onCommand;
    }

    public void setForwardCommand(Command forwardCommand) {
        this.forwardCommand = forwardCommand;
    }

    public void setBackCommand(Command backCommand) {
        this.backCommand = backCommand;
    }

    public void setLeftCommand(Command leftCommand) {
        this.leftCommand = leftCommand;
    }

    public void setRightCommand(Command rightCommand) {
        this.rightCommand = rightCommand;
    }

    public void setOffCommand(Command offCommand) {
        this.offCommand = offCommand;
    }


    /**
     * 开机
     */
    public void on(){
        onCommand.execute();
    }

    /**
     * 前进
     */
    public void forward(){
        forwardCommand.execute();
    }

    /**
     * 后退
     */
    public void back(){
        backCommand.execute();
    }

    /**
     * 右转
     */
    public void right(){
        rightCommand.execute();
    }

    /**
     * 左转
     */
    public void left(){
        leftCommand.execute();
    }

    /**
     * 关机
     */
    public void off(){
        offCommand.execute();
    }

}
